//
//  HighScoresVC.m
//  Mockup
//
//  Created by Dwayne Bates on 3/04/10.
//  Copyright 2010 Mac-Easy@USC. All rights reserved.
//

#import "HighScoresVC.h"


@implementation HighScoresVC

@synthesize namesAndScores;

@synthesize label1;
@synthesize label11;
@synthesize label2;
@synthesize label22;
@synthesize label3;
@synthesize label33;
@synthesize label4;
@synthesize label44;
@synthesize label5;
@synthesize label55;

@synthesize bgimage;

-(IBAction)backButton:(id) sender{
	[self dismissModalViewControllerAnimated:YES];
	//[myMusic stop];
}



-(IBAction)easyButton:(id) sender{
	[self showHighScoresForDifficulty:Easy];
	bgimage.image = [UIImage imageNamed:@"HS.Easy.png"];
}
-(IBAction)mediumButton:(id) sender{
	[self showHighScoresForDifficulty:Medium];
	bgimage.image = [UIImage imageNamed:@"HS.Medium.png"];
}

-(IBAction)hardButton:(id) sender{                                
	[self showHighScoresForDifficulty:Hard];
	bgimage.image = [UIImage imageNamed:@"HS.Hard.png"];
}

/*
 // The designated initializer. Override to perform setup that is required before the view is loaded.
 - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
 if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
 // Custom initialization
 }
 return self;
 }
 */

/*
 // Implement loadView to create a view hierarchy programmatically, without using a nib.
 - (void)loadView {
 }
 */



// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.      
- (void)viewDidLoad {    
	[super viewDidLoad];   
	
	// set up the labels
	label1.textColor= [UIColor yellowColor];	
	label11.textColor= [UIColor yellowColor];
	label2.textColor= [UIColor yellowColor];
	label22.textColor= [UIColor yellowColor];
	label3.textColor= [UIColor yellowColor];
	label33.textColor=[UIColor yellowColor];
	label4.textColor= [UIColor yellowColor];
	label44.textColor=[UIColor yellowColor];
	label5.textColor= [UIColor yellowColor];
	label55.textColor=[UIColor yellowColor];
	label1.font = [UIFont boldSystemFontOfSize:14];	
	label11.font = [UIFont boldSystemFontOfSize:14];
	label2.font = [UIFont boldSystemFontOfSize:14];
	label22.font = [UIFont boldSystemFontOfSize:14];
	label3.font = [UIFont boldSystemFontOfSize:14];
	label33.font = [UIFont boldSystemFontOfSize:14];
	label4.font = [UIFont boldSystemFontOfSize:14];
	label44.font = [UIFont boldSystemFontOfSize:14];
	label5.font = [UIFont boldSystemFontOfSize:14];
	label55.font = [UIFont boldSystemFontOfSize:14];
	//
//	NSString *pathToMusicFile = [[NSBundle mainBundle] pathForResource: @"music1" ofType:@"mp3"];
//	
//	myMusic = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:pathToMusicFile] error:NULL];
//	
//	myMusic.delegate = self;
//	myMusic.numberOfLoops = -1;
//	myMusic.volume = 0.2;
//	[myMusic play];
		
	[self showHighScoresForDifficulty:[Configuration getPreferredDifficulty]];	
}                                                                                                  

-(void) showHighScoresForDifficulty:(difficulty_t)difficulty {
	self.namesAndScores = [[[Configuration sharedInstance] getHighScoresForDifficulty:difficulty] retain];
	
	NSLog(@"scores: difficulty\t%d\n%@", difficulty, [self.namesAndScores description]);
	
	label1.text =	(@"%@",[[self.namesAndScores	objectAtRow:0	andCol:0]	description]);
	label11.text =	(@"%@",[[self.namesAndScores	objectAtRow:0	andCol:1]	description]);
	label2.text =	(@"%@",[[self.namesAndScores	objectAtRow:1	andCol:0]	description]);
	label22.text =	(@"%@",[[self.namesAndScores	objectAtRow:1	andCol:1]	description]);
	label3.text =	(@"%@",[[self.namesAndScores	objectAtRow:2	andCol:0]	description]);
	label33.text =	(@"%@",[[self.namesAndScores	objectAtRow:2	andCol:1]	description]);
	label4.text =	(@"%@",[[self.namesAndScores	objectAtRow:3	andCol:0]	description]);
	label44.text =	(@"%@",[[self.namesAndScores	objectAtRow:3	andCol:1]	description]);
	label5.text =	(@"%@",[[self.namesAndScores	objectAtRow:4	andCol:0]	description]);
	label55.text =	(@"%@",[[self.namesAndScores	objectAtRow:4	andCol:1]	description]);
}

/*
 // Override to allow orientations other than the default portrait orientation.
 - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
 // Return YES for supported orientations
 return (interfaceOrientation == UIInterfaceOrientationPortrait);
 }
 */

- (void)didReceiveMemoryWarning {
	// Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];
	
	// Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
	// Release any retained subviews of the main view.
	// e.g. self.myOutlet = nil;
}


- (void)dealloc {
	[self.namesAndScores release];
    
	[super dealloc];
}

@end
